package com.mxpio.erp.common.plm.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * 项目恢复申请操作
 *
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PLM_PROJECT_RECOVERY")
@Schema(description="项目恢复申请操作")
public class ProjectRecoveryOperation extends BaseEntity {

    @Id
    @Column(name = "BIZ_NO_")
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "申请单号")
    private String bizNo;

    @Column(name = "PRO_CODE_")
    @Schema(description = "项目编码")
    private String proCode;

    @Column(name = "REASON_")
    @Schema(description = "申请原因")
    private String reason;

    @Column(name = "ATTACHMENT_")
    @Schema(description = "申请附件")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String attachment;

    @Column(name = "APPLY_USER_")
    @Schema(description = "申请人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String applyUser;

    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @Column(name = "APPLY_TIME_")
    @Schema(description = "申请时间")
    private Date applyTime;

    /**审批状态*/
    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审批状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")
//    @Generator
    private String processInstanceId;

    @Column(name = "IS_AUDIT_END_")
    @Schema(description = "是否审核结束")
    @Dict(dicCode = "MB_SYSTEM_YES_NO")//1:是；0:否
    private String isAuditEnd;
}